package com.hw.higress.producer.controller;

import com.hw.higress.common.remote.ProducerClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @program: cloud-higress
 * @description:
 * @author: hewei
 * @date: 2023-07-15 11:39
 **/

@Slf4j
@RestController
@RequestMapping("/producer")
public class ProducerController implements ProducerClient {
    private DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @Override
    @GetMapping("/host")
    public String host() throws UnknownHostException {
        log.info("producer:host()");
        return "producer:" + InetAddress.getLocalHost().getHostAddress() + "[" + dtf.format(LocalDateTime.now()) + "]";
    }
}
